<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>缩放</title>
</head>
<body>
<canvas id="canvas1" width="500" height="800"></canvas>
<script>
  var ctx = document.getElementById('canvas1').getContext('2d');
  var img = new Image();   // 创建一个<img>元素
  img.src = 'aa.jpeg'; // 设置图片源地址
  img.onload = function(){
    ctx.drawImage(img, 0, 0, 200, 300);
    // drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)
    ctx.drawImage(img, 200, 100, 200, 300, 200, 200, 200, 300);
  }
</script>
</body>
</html>